package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2018/12/15 14:09
 * @description
 */
public class Code657 {
    public boolean judgeCircle(String moves) {
        int l = 0, r = 0, u = 0, d = 0;
        for (char c : moves.toCharArray()) {
            if (c == 'U') {
                u++;
            } else if (c == 'D') {
                d++;
            } else if (c == 'L') {
                l++;
            } else {
                r++;
            }
        }
        return (r == l && u == d);
    }

}
